var str = ("div#demo.demo");
    str.replace(/^(\w+)#(\w+)\.(\w+)$/,function(match,$1,$2,$3){
        return "<"+$1+" id=\"" + $2+ "\" class=\""+ $3+ "\"><\/" + $1 +">"
    })
    console.log(str);